public abstract class StringTree {
	
	protected  StringNode rootNode;
	
	public StringTree(String node) {
		this.add(node);
	}
	
	public StringTree() {
		rootNode = null;
	}
	
	public abstract String search(String node);
	
	public abstract void add(String node);
	
	public boolean contains(String node) {
		if (this.search(node).equals("Knoten wurde nicht gefunden")) {
			return false;
		}
		return true;
	}
	
	@Override
	public String toString() {
		String out = "(/) "+this.rootNode.getLabel()+'\n';
		out += this.rectoString(this.rootNode,1);
		return out;
	}
	
	private String rectoString(StringNode node, int i) {
		String out = "";
		if(!(node.getLeftChild() == null)) {
			for (int j = 0;j<i;j++) {
			out +="  "; 	
			}
			out += "(l) "+node.getLeftChild().getLabel()+'\n';
			out += this.rectoString(node.getLeftChild(),i+1);
		}
		if(!(node.getRightChild() == null)) {
			for (int j = 0;j<i;j++) {
			out +="  "; 	
			}
			out += "(r) "+node.getRightChild().getLabel()+'\n';
			out += this.rectoString(node.getRightChild(),i+1);
		}
		return out;
	}
	
}